var NineYi;
(function (n) {
    var t;
    (function (t) {
        var i;
        (function (t) {
            var i = function () {
                function t(t, i, r, u, f, e) {
                    var s = this, o, v, l;
                    if (this.$scope = t, this.$element = i, this.$log = r, this.$window = u, this.OfficialShopProfile = f, this.FreezeBodyUtility = e, o = this.$element[0], typeof this.OfficialShopProfile != "undefined" && typeof o != "undefined")if (this.OfficialShopProfile.BrowserMode === n.WebStore.Frontend.BE.Device.DeviceModeEnum.Desktop) {
                        var a = o.querySelector("#layout-header-fix"), h = a.parentElement, c = "fix-style";
                        this.$window.setTimeout(function () {
                            s.fixedOffset = h.offsetTop + a.offsetTop;
                            s.$window.addEventListener("scroll", function () {
                                s.$window.pageYOffset > s.fixedOffset ? h.classList.contains(c) || h.classList.toggle(c) : h.classList.contains(c) && h.classList.remove(c)
                            })
                        }, 2e3)
                    } else this.OfficialShopProfile.BrowserMode === n.WebStore.Frontend.BE.Device.DeviceModeEnum.Mobile ? (v = o.querySelector("#layout-header"), l = v.getAttribute("data-effect-css-class"), this.$scope.$watch(function () {
                            return s.FreezeBodyUtility.IsFreeze
                        }, function (n) {
                            n && o.classList.contains(l) && o.classList.remove(l)
                        })) : this.$log.error("BrowserMode is not expected"); else this.$log.error("OfficialShopProfile is undefined")
                }

                return t.$inject = ["$scope", "$element", "$log", "$window", "OfficialShopProfile", "FreezeBodyUtility"], t
            }();
            t.HeaderController = i;
            angular.module("NineYi.Mall.Controllers").controller("HeaderController", i)
        })(i = t.Controllers || (t.Controllers = {}))
    })(t = n.Mall || (n.Mall = {}))
})(NineYi || (NineYi = {})), function (n) {
    var t;
    (function (n) {
        var t;
        (function (n) {
            var t = function () {
                function n(n, t, i, r, u, f, e, o) {
                    var s = this;
                    this.shopId = n;
                    this.$scope = t;
                    this.$log = i;
                    this.DeviceValue = r;
                    this.$window = u;
                    this.$timeout = f;
                    this.activityService = e;
                    this.OfficialOriginDomain = o;
                    this.MaxLength = 3;
                    this.$log.info("Get ActivityList - start");
                    this.activityService.GetActivityList(this.shopId).then(function (n) {
                        n.length !== 0 && (s.ActivityList = n.map(function (n) {
                            return n.Activity_Url = s.OfficialOriginDomain + "/v2/activity/" + n.Activity_Id + "?layout=official", n
                        }), s.$log.info("Get ActivityList - Finish"))
                    })
                }

                return n.$inject = ["ShopId", "$scope", "$log", "DeviceValue", "$window", "$timeout", "ActivityService", "OfficialOriginDomain"], n
            }();
            n.HeaderActivityController = t;
            angular.module("NineYi.Theme.Components").controller("HeaderActivityController", t)
        })(t = n.Controllers || (n.Controllers = {}))
    })(t = n.Mall || (n.Mall = {}))
}(NineYi || (NineYi = {})), function (n) {
    var t;
    (function (n) {
        var t;
        (function (n) {
            var t = function () {
                function n(n, t, i, r, u, f) {
                    this.$scope = n;
                    this.$log = t;
                    this.$window = i;
                    this.shopId = r;
                    this.shopService = u;
                    this.OfficialServiceImmediate = f;
                    this.ShowBars = !1;
                    this.FreeGiftList = [];
                    this.IsOpendMenu = !1;
                    this.InitialProductCategoryList();
                    this.InitialPromotionList()
                }

                return n.prototype.InitialPromotionList = function () {
                    var n = this;
                    this.IsLoadedPromotionList = !1;
                    this.OfficialServiceImmediate.GetOfficialPromotionTargetListPromise.then(function (t) {
                        for (var u, r, i = 0; i <= t.length - 1; i++)if (u = t[i].ConditionDiscountTypeDef, t[i].Targets.length > 0 && u === "FreeGift")for (r = 0; r <= t[i].Targets.length - 1; r++)n.FreeGiftList.push(t[i].Targets[r]);
                        n.IsLoadedPromotionList = !0
                    })
                }, n.prototype.InitialProductCategoryList = function () {
                    var n = this;
                    this.shopService.GetProductCategoryList(this.shopId).then(function (t) {
                        typeof t != "undefined" && (n.ShopCategoryListInfo = t)
                    })
                }, n.$inject = ["$scope", "$log", "$window", "ShopId", "ShopService", "OfficialServiceImmediate"], n
            }();
            n.HeaderCategoryMenuController = t;
            angular.module("NineYi.Mall.Controllers").controller("HeaderCategoryMenuController", t)
        })(t = n.Controllers || (n.Controllers = {}))
    })(t = n.Mall || (n.Mall = {}))
}(NineYi || (NineYi = {})), function (n) {
    var t;
    (function (t) {
        var i;
        (function (t) {
            var i = function () {
                function t(n, t, i, r, u, f, e, o) {
                    this.value = n;
                    this.$scope = t;
                    this.$log = i;
                    this.$window = r;
                    this.shopId = u;
                    this.officialService = f;
                    this.appDownloadUtility = e;
                    this.DialogUtility = o;
                    this.ShowTouchDownloadApp = !1;
                    this.IsFocusInput = !1;
                    this.IsTouchDevice = n.isTouchDevice
                }

                return t.prototype.SendDownloadMessage = function (t) {
                    var i = this;
                    t.stopPropagation();
                    n.Mall.Configs.RegexPattern.Phone.test(this.CellPhone) ? (this.$log.info("Get AppDownLoadLink - Start"), this.officialService.GetAppDownLoadLink(this.shopId, this.CellPhone).then(function (n) {
                            i.$log.info("Get AppDownLoadLink - End");
                            i.appDownloadUtility.ShowDownloadLinkResult(i.CellPhone, n.ReturnCode);
                            i.CellPhone = ""
                        })) : this.DialogUtility.Notice("手機格式不正確");
                    this.ShowTouchDownloadApp = !1;
                    this.IsFocusInput = !1
                }, t.$inject = ["Mall.Value", "$scope", "$log", "$window", "ShopId", "OfficialService", "AppDownloadUtility", "DialogUtility"], t
            }();
            t.HeaderDownloadAppController = i;
            angular.module("NineYi.Theme.Components").controller("HeaderDownloadAppController", i)
        })(i = t.Controllers || (t.Controllers = {}))
    })(t = n.Mall || (n.Mall = {}))
}(NineYi || (NineYi = {})), function (n) {
    var t;
    (function (n) {
        var t;
        (function (n) {
            var t = function () {
                function n(n, t, i, r, u, f, e, o, s, h, c) {
                    var l = this;
                    this.shopId = n;
                    this.$rootScope = t;
                    this.value = i;
                    this.$scope = r;
                    this.$log = u;
                    this.$window = f;
                    this.authService = e;
                    this.AuthServiceImmediate = o;
                    this.googleAnalyticsUtility = s;
                    this.dialogUtility = h;
                    this.favoriteUtility = c;
                    this.FavCount = 0;
                    this.IsLogin = !1;
                    this.IsTouchDevice = i.isTouchDevice;
                    this.favoriteUtility.AfterRefresh(function () {
                        l.UpdateFavCount()
                    });
                    this.$log.info("Get Auth IsLogin - Start");
                    this.AuthServiceImmediate.IsLoginPromise.then(function (n) {
                        l.IsLogin = n;
                        l.$log.info("Get Auth IsLogin - Finish", n);
                        l.GetFavCount()
                    })
                }

                return n.prototype.UpdateFavCount = function () {
                    this.FavCount = this.favoriteUtility.FavCount;
                    this.$log.info("Update TraceSalePageList Count", this.FavCount)
                }, n.prototype.GetFavCount = function () {
                    var n = this;
                    this.favoriteUtility.GetFavCount().then(function (t) {
                        n.FavCount = t
                    })
                }, n.prototype.ToggleMyAccountMenu = function (n) {
                    n.preventDefault();
                    n.stopPropagation();
                    this.IsShowMyAccountMenu = !this.IsShowMyAccountMenu
                }, n.prototype.TrackEvent = function (n, t, i, r) {
                    this.googleAnalyticsUtility.TrackEvent(n, t, i, r)
                }, n.prototype.Login = function (n) {
                    n.preventDefault();
                    n.stopPropagation();
                    this.$window.location.href = "/Login/HttpLoginRelayToHttps/?rt=" + this.$window.location.href.replace(this.$window.location.hash, "") + "&reason=notlogin"
                }, n.prototype.Logout = function (n) {
                    var t = this;
                    n.preventDefault();
                    n.stopPropagation();
                    this.authService.Logout().success(function () {
                        t.dialogUtility.AutoCloseNotice("登出成功！").then(function () {
                            t.$window.location.reload()
                        })
                    })
                }, n.$inject = ["ShopId", "$rootScope", "Mall.Value", "$scope", "$log", "$window", "AuthService", "AuthServiceImmediate", "GoogleAnalyticsUtility", "DialogUtility", "FavoriteUtility"], n
            }();
            n.HeaderMyAccountController = t;
            angular.module("NineYi.Mall.Controllers").controller("HeaderMyAccountController", t)
        })(t = n.Controllers || (n.Controllers = {}))
    })(t = n.Mall || (n.Mall = {}))
}(NineYi || (NineYi = {})), function (n) {
    var t;
    (function (n) {
        var t;
        (function (n) {
            var t = function () {
                function n(n, t, i) {
                    var r = this;
                    this.$window = n;
                    this.deviceValue = t;
                    this.FreezeBodyUtility = i;
                    this.IsShow = !1;
                    this.$window.onload = function () {
                        (r.deviceValue.IsMobile() || r.deviceValue.isTouchDevice) && (r.TouchDeviceSearchBtnDomElement = document.querySelector(".search-area-full-screen .ns-search-btn"))
                    }
                }

                return n.prototype.ShowSearchArea = function (n) {
                    n.stopPropagation();
                    this.IsShow = !0;
                    this.TouchDeviceSearchInputDomElement = document.querySelector(".search-area-full-screen .ns-search-input");
                    this.TouchDeviceSearchInputDomElement.focus();
                    this.TouchDeviceSearchInputDomElement.addEventListener("keyup", this.KeyboardEnter.bind(this))
                }, n.prototype.HideSearchArea = function (n) {
                    n.preventDefault();
                    n.stopPropagation();
                    this.IsShow = !1;
                    this.UnFreezeBody()
                }, n.prototype.FreezeBody = function () {
                    this.FreezeBodyUtility.FreezeBody()
                }, n.prototype.UnFreezeBody = function () {
                    this.FreezeBodyUtility.UnFreezeBody()
                }, n.prototype.KeyboardEnter = function (n) {
                    n.keyCode === 13 && this.TouchDeviceSearchBtnDomElement.click()
                }, n.$inject = ["$window", "DeviceValue", "FreezeBodyUtility"], n
            }();
            n.HeaderSearchBarController = t;
            angular.module("NineYi.Mall.Controllers").controller("HeaderSearchBarController", t)
        })(t = n.Controllers || (n.Controllers = {}))
    })(t = n.Mall || (n.Mall = {}))
}(NineYi || (NineYi = {})), function (n) {
    var t;
    (function (n) {
        var t;
        (function (n) {
            var t = function () {
                function n(n, t, i, r, u, f, e, o, s) {
                    var h = this;
                    this.$scope = n;
                    this.$rootScope = t;
                    this.$log = i;
                    this.$window = r;
                    this.$timeout = u;
                    this.ShopId = f;
                    this.ShoppingCartService = e;
                    this.googleAnalyticsEcommerceUtility = o;
                    this.dialogUtility = s;
                    this.ShoppingCartCount = 0;
                    this.RefreshShoppingCartCount();
                    t.$on("RefreshShoppingCartCount", function () {
                        h.$log.info("Event - RefreshShoppingCartCount");
                        h.RefreshShoppingCartCount()
                    })
                }

                return n.prototype.RefreshShoppingCartCount = function () {
                    var n = this;
                    this.ShoppingCartService.GetCount(this.ShopId).then(function (t) {
                        n.ShoppingCartCount = t;
                        n.ShoppingCartPreviewData = null
                    })
                }, n.prototype.LoadShoppingCartPreview = function () {
                    var n = this;
                    this.ShoppingCartPreviewData || (this.$log.info("Get ShoppingCart Preview - Start", this.ShopId), this.ShoppingCartService.GetPreview(this.ShopId).then(function (t) {
                        n.$log.info("Get ShoppingCart Preview - Finish", t);
                        n.ShoppingCartPreviewData = t
                    }))
                }, n.prototype.RemoveFromShoppingCart = function (n, t) {
                    var i = this;
                    this.ShoppingCartService.RemoveItem(this.ShopId, t.SalePageId, t.SaleProductSKUId, t.SalePageGroupSeq).success(function () {
                        i.ShoppingCartPreviewData.ShopList[0].SalePageList.splice(n, 1);
                        i.dialogUtility.AutoCloseNotice("移除成功！");
                        var r = {id: t.SalePageId.toString(), name: t.Title, price: t.Price};
                        i.googleAnalyticsEcommerceUtility.RemoveFromCart(r);
                        i.ShoppingCartCount = i.ShoppingCartPreviewData.ShopList[0].SalePageList.length;
                        i.ShoppingCartPreviewData = null;
                        i.LoadShoppingCartPreview()
                    })
                }, n.prototype.CheckOut = function () {
                    this.$window.location.href = "/V2/ShoppingCart/Index?shopId=" + this.ShopId
                }, n.$inject = ["$scope", "$rootScope", "$log", "$window", "$timeout", "ShopId", "ShoppingCartService", "GoogleAnalyticsEcommerceUtility", "DialogUtility"], n
            }();
            n.HeaderShoppingCartController = t;
            angular.module("NineYi.Theme.Components").controller("HeaderShoppingCartController", t)
        })(t = n.Controllers || (n.Controllers = {}))
    })(t = n.Mall || (n.Mall = {}))
}(NineYi || (NineYi = {})), function (n) {
    var t;
    (function (n) {
        var t;
        (function (n) {
            var t = function () {
                function n(n, t) {
                    var i = this;
                    this.$log = n;
                    this.LayoutTemplateDataServiceImmediate = t;
                    this.LayoutTemplateDataServiceImmediate.GetCustomLinkPromise.then(function (n) {
                        i.CustomLinks = n.Data.filter(function (n) {
                            return n.Data.length > 0
                        });
                        i.$log.debug("取得自訂連結資料CustomLinks" + i.CustomLinks)
                    })
                }

                return n.$inject = ["$log", "LayoutTemplateDataServiceImmediate"], n
            }();
            n.HeaderCustomLinksController = t;
            angular.module("NineYi.Mall.Controllers").controller("HeaderCustomLinksController", t)
        })(t = n.Controllers || (n.Controllers = {}))
    })(t = n.Mall || (n.Mall = {}))
}(NineYi || (NineYi = {})), function (n) {
    var t;
    (function (t) {
        var i;
        (function (t) {
            var i = function () {
                function t(n, t, i, r, u, f, e, o, s, h) {
                    this.config = n;
                    this.$rootScope = t;
                    this.$scope = i;
                    this.$log = r;
                    this.ShopId = u;
                    this.OfficialService = f;
                    this.appDownloadUtility = e;
                    this.DialogUtility = o;
                    this.CookieUtility = s;
                    this.UrlUtility = h;
                    this.SetCommonCookie("fr", this.config.cookieExpireTimeForFR);
                    this.SetCommonCookie("fr2", this.config.cookieExpireTimeForFR);
                    this.SetCommonCookie("act", this.config.cookieExpireTimeForACT)
                }

                return t.prototype.sendDownloadMessage = function (t) {
                    var i = this;
                    t.stopPropagation();
                    n.Mall.Configs.RegexPattern.Phone.test(this.cellphone) ? (this.$log.info("Get AppDownLoadLink - Start"), this.OfficialService.GetAppDownLoadLink(this.ShopId, this.cellphone).then(function (n) {
                            i.$log.info("Get AppDownLoadLink - End");
                            i.appDownloadUtility.ShowDownloadLinkResult(i.cellphone, n.ReturnCode);
                            i.cellphone = ""
                        })) : this.DialogUtility.Notice("手機格式不正確")
                }, t.prototype.SetCommonCookie = function (n, t) {
                    var i, r;
                    document.location.hostname.match(/service.91app/) || (i = this.UrlUtility.GetQuerystring(n), i && (this.CookieUtility.AddCookie("trace-" + n, i), r = this.CookieUtility.SetCookieExpireTime("trace-" + n, t), this.CookieUtility.AddCookie("trace-" + n + "-expires", r), this.CookieUtility.SetCookieExpireTime("trace-" + n + "-expires", t)))
                }, t.$inject = ["Mall.Config", "$rootScope", "$scope", "$log", "ShopId", "OfficialService", "AppDownloadUtility", "DialogUtility", "CookieUtility", "UrlUtility"], t
            }();
            t.SharedFooterController = i;
            angular.module("NineYi.Mall.Controllers").controller("SharedFooterController", i)
        })(i = t.Controllers || (t.Controllers = {}))
    })(t = n.Mall || (n.Mall = {}))
}(NineYi || (NineYi = {})), function (n) {
    var t;
    (function (n) {
        var t;
        (function (n) {
            var t = function () {
                function n(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d) {
                    var g = this;
                    this.shopId = n;
                    this.$scope = t;
                    this.$log = i;
                    this.$q = r;
                    this.config = u;
                    this.$window = f;
                    this.googleAnalyticsUtility = e;
                    this.OfficialServiceImmediate = o;
                    this.shopServiceImmediate = s;
                    this.salePageCategoryId = h;
                    this.UrlUtility = c;
                    this.activityService = l;
                    this.promotionV2ServiceImmediate = a;
                    this.couponServiceImmediate = v;
                    this.eCouponServiceImmediate = y;
                    this.MainMenuUtility = p;
                    this.RefUtility = w;
                    this.PageValue = b;
                    this.OfficialShopProfile = k;
                    this.OfficialOriginDomain = d;
                    this.FreeGiftList = [];
                    this.HasStoreInfo = this.OfficialShopProfile.StoreTotalCount > 0;
                    this.couponServiceImmediate.GetCouponListPromise.then(function (n) {
                        g.HasCoupon = n && n.length > 0
                    });
                    this.InitialCategoryMenu()
                }

                return n.prototype.SetActiveLink = function (n, t) {
                    this.SimpleMode = !1;
                    var i = this;
                    if (t === this.config.allSalePageCategoryId) {
                        n[0].active = !0;
                        return
                    }
                    [].slice.call(n).forEach(function (n) {
                        if (+n.ShopCategory_Id == +t) {
                            n.active = !0;
                            n.ChildList && n.ChildList.length > 0 && (i.SimpleMode = !0, n.selected = !0);
                            return
                        }
                        n.ChildList && [].slice.call(n.ChildList).forEach(function (r) {
                            if (+r.ShopCategory_Id == +t) {
                                r.active = !0;
                                n.selected = !0;
                                i.SimpleMode = !0;
                                return
                            }
                        })
                    })
                }, n.prototype.ToggleCategoryLevel1 = function (n) {
                    n.selected = !n.selected
                }, n.prototype.ClickCategoryLevel1 = function (n) {
                    n.ChildList && n.ChildList.length > 0 ? this.ToggleCategoryLevel1(n) : (n.active = !0, this.$window.location.href = this.OfficialOriginDomain + "/v2/official/SalePageCategory/" + n.ShopCategory_Id, this.TrackEvent("全站_Header", "Menu", "商品分類"))
                }, n.prototype.HasFreeGift = function (n) {
                    return this.FreeGiftList.indexOf(n.ShopCategory_Id) >= 0
                }, n.prototype.OpenMenu = function (n) {
                    this.MainMenuUtility.Open(n)
                }, n.prototype.TrackEvent = function (n, t, i, r) {
                    this.googleAnalyticsUtility.TrackEvent(n, t, i, r)
                }, n.prototype.GoToDownloadApp = function () {
                    var n = this.RefUtility.ReplaceRefUrl(this.PageValue.CurrentPage);
                    this.$window.open(n, "_blank")
                }, n.prototype.CloseMenu = function () {
                    this.MainMenuUtility.Close()
                }, n.prototype.CheckHasDiscountPromotion = function () {
                    var t = this, n = this.$q.defer();
                    return this.HasDiscountPromotion = !1, this.promotionV2ServiceImmediate.GetPromotionListPromise.then(function (i) {
                        t.HasDiscountPromotion = i.ReturnCode === "API0001" && i.Data.PromotionCount > 0;
                        n.resolve()
                    }).catch(function () {
                        n.reject()
                    }), n.promise
                }, n.prototype.CheckHasECoupon = function () {
                    var t = this, n = this.$q.defer();
                    return this.eCouponServiceImmediate.GetOfficialECouponListPromise.then(function (i) {
                        i && i[0] && (t.HasECoupon = i[0].ECouponList.length > 0);
                        n.resolve()
                    }).catch(function () {
                        n.reject()
                    }), n.promise
                }, n.prototype.InitialActivityList = function () {
                    var n = this, t = this.$q.defer();
                    return this.$log.info("Get ActivityList - start"), this.activityService.GetActivityList(this.shopId).then(function (i) {
                        i && (n.ActivityList = i.map(function (t) {
                            return t.Activity_Url = n.OfficialOriginDomain + "/v2/activity/" + t.Activity_Id + "?layout=official", t
                        }));
                        n.$log.info("Get ActivityList - Finish");
                        t.resolve()
                    }).catch(function () {
                        t.reject()
                    }), t.promise
                }, n.prototype.InitialCategoryMenu = function () {
                    var n = this, t;
                    this.shopServiceImmediate.GetShopCategoryListPromise.then(function (t) {
                        if (n.ShopCategoryData = t, n.ShopCategoryData && n.ShopCategoryData.List.length > 0)if (typeof n.salePageCategoryId != "undefined") n.SetActiveLink(n.ShopCategoryData.List, n.salePageCategoryId); else {
                            var i = parseInt(n.UrlUtility.GetQuerystring("cid"));
                            i && (n.salePageCategoryId = i, n.SetActiveLink(n.ShopCategoryData.List, n.salePageCategoryId))
                        }
                    });
                    this.OfficialServiceImmediate.GetOfficialPromotionTargetListPromise.then(function (t) {
                        for (var u, r, i = 0; i <= t.length - 1; i++)if (u = t[i].ConditionDiscountTypeDef, t[i].Targets.length > 0 && u === "FreeGift")for (r = 0; r <= t[i].Targets.length - 1; r++)n.FreeGiftList.push(t[i].Targets[r]);
                        n.IsLoadedPromotionList = !0
                    });
                    t = [this.InitialActivityList(), this.CheckHasDiscountPromotion(), this.CheckHasECoupon()];
                    this.$q.all(t).then(function () {
                        n.IsShowActivityAndOffers = n.HasECoupon || n.ActivityList && n.ActivityList.length > 0 || n.HasDiscountPromotion
                    })
                }, n.$inject = ["ShopId", "$scope", "$log", "$q", "Mall.Config", "$window", "GoogleAnalyticsUtility", "OfficialServiceImmediate", "ShopServiceImmediate", "SalePageCategoryId", "UrlUtility", "ActivityService", "PromotionV2ServiceImmediate", "CouponServiceImmediate", "ECouponServiceImmediate", "MainMenuUtility", "RefUtility", "PageValue", "OfficialShopProfile", "OfficialOriginDomain"], n
            }();
            n.AsideCategoryMenuController = t;
            angular.module("NineYi.Mall.Controllers").controller("AsideCategoryMenuController", t)
        })(t = n.Controllers || (n.Controllers = {}))
    })(t = n.Mall || (n.Mall = {}))
}(NineYi || (NineYi = {})), function (n) {
    var t;
    (function (n) {
        var t;
        (function (n) {
            var t = function () {
                function n(n, t) {
                    this.$log = n;
                    this.ComponentControlFactory = t;
                    this.IsEnable = !1;
                    this.IsEnable = this.ComponentControlFactory.IsEnableToolbox
                }

                return n.$inject = ["$log", "ComponentControlFactory"], n
            }();
            n.CommonToolboxController = t;
            angular.module("NineYi.Mall.Controllers").controller("CommonToolboxController", t)
        })(t = n.Controllers || (n.Controllers = {}))
    })(t = n.Mall || (n.Mall = {}))
}(NineYi || (NineYi = {}))